# -*- coding: utf-8 -*-
'''
豆瓣分类电影排行榜
根据对应页面的动态文件获取url，请求类型，请求参数
'''
import requests
url = 'https://movie.douban.com/j/chart/top_list'
proxies = {"http": None, "https": None}
# 很明显，这个start和limit参数就是排行名次，和拿多少条排名数据的参数了，这里只取了前20条
params = {
    'type' : '5',
    'interval_id' : '100:90',
    'action' : '',
    'start' : '0',
    'limit' : '20'
}
headers = {
    'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Mobile Safari/537.36'
}
response = requests.get(url=url, params=params, headers=headers, proxies=proxies)
# 可以先把这个json数据打印出来看看数据，然后根据对应的标签取数据
page_text = response.json()
for movie in page_text:
    name = movie['title']    # 电影名
    score = movie['score']   # 评分
    types = movie['types']   # 种类
    actor = movie['actors']   # 演员
    regions = movie['regions']    # 地区
    print(name, score, types, actor, regions)